package com.fulihui.systemcore.repository.impl;

import com.fulihui.systemcore.dal.convertor.VisitRecordConv;
import com.fulihui.systemcore.dal.mapper.VisitRecordMapper;
import com.fulihui.systemcore.dto.VisitRecordDTO;
import com.fulihui.systemcore.repository.VisitRecordRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by leeson on 2016/6/6.
 */
@Repository
public class VisitRecordRepositoryImpl implements VisitRecordRepository {
    @Autowired
    private VisitRecordMapper visitRecordMapper;

    @Override
    public VisitRecordDTO querySingle(Integer id) {
        return VisitRecordConv.convert2DTO(visitRecordMapper.querySingle(id));
    }

    @Override
    public void insert(VisitRecordDTO record) {
        visitRecordMapper.insert(VisitRecordConv.convert2DO(record));
    }

    @Override
    public void update(VisitRecordDTO record) {
        visitRecordMapper.update(VisitRecordConv.convert2DO(record));
    }

    @Override
    public List<VisitRecordDTO> queryPage(String nickName, String phone, String stratTime,
                                          String endTime, int page, int rows) {
        return VisitRecordConv.convert2List(
            visitRecordMapper.queryPage(nickName, phone, stratTime, endTime, page, rows));
    }

    @Override
    public int queryPageCount(String nickName, String phone, String stratTime, String endTime) {
        return visitRecordMapper.queryPageCount(nickName, phone, stratTime, endTime);
    }

    @Override
    public List<VisitRecordDTO> queryAll(String nickName, String phone, String stratTime,
                                         String endTime) {
        return VisitRecordConv
            .convert2List(visitRecordMapper.queryAll(nickName, phone, stratTime, endTime));
    }
}
